package com.app.util.date;

public class Countdown {

	private boolean started = false;

	/** 计时变量 */
	private long timeCount;
	private long start;

	/** 格式化 */
	private String format;

	/**
	 * 开始计时
	 */
	public void start() {
		if (started) {
			return;
		}
		start = System.currentTimeMillis();
		started = true;
	}

	/** 
	 * 剩余时间
	 * 
	 * @return
	 */
	public long timeLeft() {
		return timeCount - (System.currentTimeMillis() - start);
	}

	public String toString() {
		return TimeUtil.format(timeLeft(), format);
	}

	public long getTimeCount() {
		return timeCount;
	}

	public void setTimeCount(long timeCount) {
		this.timeCount = timeCount;
	}

	public String getFormat() {
		return format;
	}

	public void setFormat(String format) {
		this.format = format;
	}

}
